<template>
  <div class="app-container">
    <el-form label-width="120px" :model="ruleForm" ref="ruleForm">
      <el-row :gutter="24" style="margin-bottom: 60px;">
        <el-divider content-position="left">
          <legend class="divider-line">优惠券审核</legend>
        </el-divider>
        <el-col :span="24">
          <el-form-item label="优惠券名称：">
            <div class="yxkj-word-black">{{ coupon.couponName }}</div>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="优惠券前缀：">
            <div class="yxkj-word-black">{{ coupon.prefix }}</div>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="优惠券面值：">
            <div class="yxkj-word-black">{{ coupon.couponValue }}</div>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="订单金额：">
            <div class="yxkj-word-black">{{ coupon.minAmount }}</div>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="发放时间：">
            <div class="yxkj-word-black">
              {{ coupon.sendStartTime }} - {{ coupon.sendEndTime }}
            </div>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="使用时间：">
            <div class="yxkj-word-black">
              {{ coupon.useStartTime }} - {{ coupon.useEndTime }}
            </div>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="操作：">
            <template>
              <el-radio v-model="ruleForm.status" label="3">审核通过</el-radio>
              <el-radio v-model="ruleForm.status" label="4">审核驳回</el-radio>
            </template>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="审核意见：">
            <el-input
              type="textarea"
              maxlength="100"
              :rows="3"
              placeholder="请输入内容"
              v-model="ruleForm.auditOpinion"
            ></el-input>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row :gutter="24">
        <div class="fixed-bottom-20">
          <el-button type="danger" @click="submitForm()">立即提交</el-button>
          <el-button type="success" @click="back()">返回</el-button>
        </div>
      </el-row>
    </el-form>
  </div>
</template>
<script>
import { auditCoupon, doauditCoupon } from "@/api/promotionbasics";
import { getCodeManager } from "@/api/all";
import { Message } from "element-ui";
export default {
  name: "couponaudit",
  data() {
    return {
      coupon: {},
      ruleForm: {
        id: "",
        status: "3",
        auditOpinion: ""
      }
    };
  },
  created() {
    let id = this.$route.query.id;
    auditCoupon({ couponId: id }).then(res => {
      this.coupon = res.data.data.coupon;
    });
    getCodeManager("ACT_STATUS,CHANNEL,COUPON_TYPE", () => {});
  },
  methods: {
    back() {
      history.back();
    },
    submitForm() {
      this.ruleForm.id = this.coupon.id;
      doauditCoupon(this.ruleForm).then(res => {
        if (!res.data.success) {
          Message.error(res.data.message);
          return;
        }
        Message.success("操作成功");
        history.back();
      });
    }
  }
};
</script>
<style scoped>
.divider-line {
  font-size: 20px;
  font-weight: 300;
}
.el-form-item {
  margin-bottom: 5px;
}
.picture-list {
  display: flex;
}
.picture-list li {
  list-style: none;
  margin-right: 10px;
}
</style>
